home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE background PUBLIC "-//Apple, Inc.//DTD background V 2.0//EN" "" >
- <background>
- <id>3808</id>
- <filler1>0</filler1>
- <bitmap>BMAP_7304.pbm</bitmap>
- <cantDelete> <true /> </cantDelete>
- <showPict> <true /> </showPict>
- <dontSearch> <false /> </dontSearch>
- <link rel="stylesheet" type="text/css" href="stylesheet_3179.css" />
- <part>
- <id>1</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>330</left>
- <top>23</top>
- <right>406</right>
- <bottom>42</bottom>
- </rect>
- <style>shadow</style>
- <showName> <true /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>center</textAlign>
- <font>Helvetica</font>
- <textSize>10</textSize>
- <textStyle>bold</textStyle>
- <name>Read aete</name>
- <script>On MouseWithin
- ShowBalloon "Click here to read the aete resource of an application to generate glue routines for it."
- End MouseWithin
-
- on mouseUp
- put MergeAete() into aete
- if aete is empty then
- answer "Unable to read the aete" with "Cancel"
- else
- AEStopTargeting
- put line 1 of aete into field targetApp
- AEStartTargeting line 1 of aete,"NoLaunch"
- set cursor to watch
- put "" into sampleCode
- put "" into field "eventList"
- put "" into field "myMsgBox"
- put "" into elementList
- put "" into enumInfo
- put "" into classNameList
- put "" into keyFormList
- put "" into hierarchyList
- put "" into compareList
- put line 8 of aete into suiteCount
- put 8 into linesRead
- repeat suiteCount times
- set cursor to busy
- put line linesRead+6 of aete into eventCount
- add 6 to linesRead
- repeat eventCount times
- set cursor to busy
- put line linesRead+11 of aete into paramCount
- add paramCount*5+11 to linesRead -- skip extra param
- end repeat -- for every event
- put line linesRead+1 of aete into classCount
- add 1 to linesRead
- repeat with classIndex = 1 to classCount
- set cursor to busy
- put (line linesRead+2 of aete) & "," & StripSp(line linesRead+1 of aete) after classNameList
- put (line linesRead+2 of aete) after hierarchyList
- put line linesRead+4 of aete into propCount
- --add propCount * 5 + 5 to linesRead -- skip prop
- add 5 to linesRead
- repeat with propIndex = 1 to propCount
- set cursor to busy
- put "," & (line linesRead of aete) & "," & (line linesRead+1 of aete) after classNameList
- add 5 to linesRead
- end repeat
- put return after classNameList
- put line linesRead of aete into elemCount
- repeat with elemIndex = 1 to elemCount
- set cursor to busy
- put line linesRead+1 of aete into elementClass
- put "," & elementClass after hierarchyList
- put line linesRead+2 of aete into keyFormCount
- add 2 to linesRead
- put number of lines in elementList into jCount
- put 0 into thisElementIndex
- repeat with j = 1 to jCount
- set cursor to busy
- if elementClass = item 1 of line j of elementList then
- put j into thisElementIndex
- exit repeat
- end if
- end repeat
- if thisElementIndex = 0 then -- add an new item
- put elementClass & return after elementList
- put jCount+1 into thisElementIndex
- end if
- repeat with keyFormIndex = 1 to keyFormCount
- set cursor to busy
- add 1 to linesRead
- put ResType(line linesRead of aete) into thisKeyForm
- put thisKeyForm after hierarchyList
- if offset("," & thisKeyForm, line thisElementIndex of elementList) = 0 then
- put "," & thisKeyForm after line thisElementIndex of elementList
- end if
- end repeat
- end repeat -- for every element
- put return after hierarchyList
- end repeat -- for every class
- add 1 to linesRead
- put line linesRead of aete into compareCount
- add 1 to linesRead
- repeat compareCount times
- set cursor to busy
- put ResType(line linesRead+1 of aete) & "," after compareList
- put StripSP(line linesRead+2 of aete) & "Test" into thisName
- put "Function " & thisName & " Obj1, obj2" & return after sampleCode
- put " return AECompareSpec(" & quote & line linesRead+1 of aete ¬
- & quote & ", obj1, obj2)" & return after sampleCode
- put "End " & thisName & return & return after sampleCode
- add 3 to linesRead
- end repeat
- put line linesRead of aete into enumerationCount
- repeat enumerationCount times
- set cursor to busy
- put line linesRead+1 of aete into x
- put (x = "kfrm") into forKeyForm
- put line linesRead+2 of aete into enumeratorCount
- add 2 to linesRead
- repeat with enumeratorIndex = 1 to enumeratorCount
- set cursor to busy
- put "," & (line linesRead+1 of aete) & "," & (line linesRead+2 of aete) after x
- add 3 to linesRead
- end repeat -- for every enumerators
- put x & return after enumInfo
- if forKeyForm then
- delete item 1 of x
- put x into keyFormList
- end if
- end repeat
- end repeat
- If keyFormList = "" then
- put "Index,indx,Named,name,ID,id " into keyFormList
- end if
- put MakePickClassName(classNameList) after sampleCode
- put classNameList into field "classNameList"
- put hierarchyList into field "hierarchyList"
- put keyFormList into field "keyFormList"
- put compareList into field "compareList"
- put ClassSample(elementList, classNameList, keyFormList) after sampleCode
- put 8 into linesRead
- repeat suiteCount times
- set cursor to busy
- put line linesRead+3 of aete into suiteCode
- put line linesRead+1 of aete into suiteName
- put line linesRead+2 of aete into suiteComment
- put line linesRead+6 of aete into eventCount
- add 6 to linesRead
- repeat eventCount times
- set cursor to busy
- put "" into paramInfo
- put line linesRead+1 of aete into eventName
- put line linesRead+2 of aete into eventComment
- put line linesRead+3 of aete into eventClass
- put line linesRead+4 of aete into eventID
- put ",," into x -- put in the reply
- put line linesRead+5 of aete into item 3 of x
- put line linesRead+7 of aete into item 4 of x
- put line linesRead+6 of aete into item 5 of x
- put x into line 1 of paramInfo
- put ",," into x -- put in the direct parameters
- put line linesRead+8 of aete into item 3 of x
- put line linesRead+10 of aete into item 4 of x
- put line linesRead+9 of aete into item 5 of x
- put x into line 2 of paramInfo
- put line linesRead+11 of aete into paramCount
- add 11 to linesRead
- repeat with paramIndex = 1 to paramCount
- set cursor to busy
- put "" into x
- put line linesRead+1 of aete into item 1 of x
- put line linesRead+2 of aete into item 2 of x
- put line linesRead+3 of aete into item 3 of x
- put line linesRead+5 of aete into item 4 of x
- put line linesRead+4 of aete into item 5 of x
- add 5 to linesRead
- put x into line (paramIndex+2) of paramInfo
- end repeat
- put EventSample(eventName, ResType(eventClass), ResType(eventID), paramInfo, enumInfo) after sampleCode
- HyperTalkTemplate eventName, eventComment, paramInfo, enumInfo
- end repeat -- for every event
- put line linesRead+1 of aete into classCount
- add 1 to linesRead
- repeat with classIndex = 1 to classCount
- set cursor to busy
- put line linesRead+4 of aete into propCount
- add propCount * 5 + 5 to linesRead -- skip prop
- put line linesRead of aete into elemCount
- repeat with elemIndex = 1 to elemCount
- put line linesRead+2 of aete into keyFormCount
- add keyFormCount + 2 to linesRead -- skip key Form
- end repeat -- for every element
- end repeat -- for every class
- add 1 to linesRead
- put line linesRead of aete into compareCount
- add compareCount*3+1 to linesRead -- skip compare
- put line linesRead of aete into enumerationCount
- repeat enumerationCount times
- set cursor to busy
- put line linesRead+2 of aete into enumeratorCount
- add enumeratorCount*3+2 to linesRead -- skip enumerators
- end repeat
- end repeat
- CmdOrObjButton
- if length(sampleCode) < 32000 then
- set script of this card to sampleCode
- else
- ask file "Script is too big, save to file?"
- if it <> "" then
- put it into ref
- open file ref
- write sampleCode to file ref
- close file ref
- end if
- end if
- end if
- end mouseUp
-
- function EventSample eventName, eventClass, eventID, paramInfo, enumInfo
- put -1 into defaultTimeOut
- put field "targetApp" into defaultTarget
- put char 1 to 2 of eventName into x
- if (x = "#*") or (x = "#$") then
- put "*" into defaultTarget
- end if
- put "AE" & StripSP(EventName) into EventName
- put (item 3 of paramInfo <> "null") into isFunc
- if isFunc then
- put "Function" into header
- else
- put "On" into header
- end if
- put space & EventName after header
- put space & NumToChar(194) & return into cont
- put " put " & quote & "AESend " & quote & " & quote & " & quote & eventClass & eventID & quote & " & quote & " & quote & "," & quote & cont after sendHeader
- put " & quote & " & quote & defaultTarget & quote & " & quote & " & quote & "," & quote & cont after sendHeader
- put " & " & quote after sendHeader
- put " AESend " & quote & eventClass & eventID & quote & "," ¬
- & quote & defaultTarget & quote & "," into shortHeader
- if isFunc then
- put "3," after sendHeader
- put "3," after shortHeader
- else
- put "1," after sendHeader
- put "1," after shortHeader
- end if
- put defaultTimeOut & quote after sendHeader
- put defaultTimeOut after shortHeader
- put line 2 of paramInfo into x
- put (item 3 of x <> "null") into hasDirect
- put (item 4 of x > 32767) into directOptional
- put 1 into paramIndex
- put false into hasOptional
- put number of lines in paramInfo into count
- repeat with index = 2 to count
- set cursor to busy
- put line index of paramInfo into x
- put item 4 of x into temp
- put (temp > 32767) into isOptional
- if item 3 of x <> "null" then
- if isOptional then
- if index <> 2 then
- put true into hasOptional
- end if
- else
- put temp div 8192 into temp
- put (temp mod 2) = 1 into isEnum
- if index = 2 then
- -- first parameter is the direct parameter
- if paramIndex = 1 then
- put " " after header
- else
- put "," after header
- end if
- put "directParam" after header
- put "----" into item 2 of x
- put HTKeyWord(x) into thisType
- if length(thisType) > 4 then
- -- we need a keyword for directParam because there is a type
- put " & " & quote & "," & quote & " & quote & " & quote & thisType & quote & " & quote " after sendHeader
- put "," & quote & thisType & quote after shortHeader
- if char 5 to 8 of thisType = "enum" then
- put EnumLines(enumInfo, 1,item 3 of x, "directParam", true) after rst
- end if
- end if
- put " & " & quote & ",directParam" & quote after sendHeader
- put ",directParam" after shortHeader
- add 1 to paramIndex
- else
- put StripSP(item 1 of x) into temp
- if paramIndex = 1 then
- put " " after header
- else
- put "," after header
- end if
- put temp after header
- -- put in the keyword
- put HTKeyWord(x) into thisType
- if (temp = "class") and (item 3 of x = "type") then
- put "PickClassName(" & temp & ")" into temp
- end if
- put " & " & quote & "," & quote & " & quote & " & quote ¬
- & thisType & quote & " & quote & " & quote & "," & temp & quote after sendHeader
- put "," & quote & thisType & quote & "," & temp after shortHeader
- if char 5 to 8 of thisType = "enum" then
- put EnumLines(enumInfo, 1,item 3 of x, temp, true) after rst
- end if
- add 1 to paramIndex
- end if
- end if
- end if
- end repeat -- 2 to n
- if (hasOptional) or (hasDirect and directOptional) then -- not all param are required
- put header & return & sendHeader & " after stmt" & return before rst
- if hasDirect and directOptional then
- put " put " & paramIndex & " into i" & return after rst
- -- we have a optional direct parameter
- put " if (the ParamCount" after rst
- if paramIndex > 1 then put space & "- " & paramIndex-1 after rst
- put ") mod 2 = 1 then" & return after rst
- put line 2 of paramInfo into x
- put "----" into item 2 of x
- put HTKeyWord(x) into thisType
- put false into paramIsUp -- we have not put Param up yet
- if (paramIndex > 1) or (length(thisType) > 4) then
- -- we have to fake a keyword
- put " put " & quote & "," & quote & " & quote & " & quote & thisType & quote & " & quote after stmt" & return after rst
- if char 5 to 8 of thisType = "enum" then
- put EnumLines(enumInfo, 2, item 3 of x, "Param(i)", false) into temp
- if temp <> "" then
- put " put " & quote & "," & quote & " after stmt" & return after rst
- put " else" into last line of temp
- put " put " & quote & "Param(" & quote & " & i & " & quote & ")" & quote & " after stmt" & return after temp
- put " end if" & return after temp
- put temp after rst
- put true into paramIsUp -- now we have put Param up
- end if
- end if
- end if
- if not paramIsUp then
- put " put " & quote & ",Param(" & quote & " & i & " & quote & ")" & quote & " after stmt" & return after rst
- end if
- if hasOptional then
- -- increment i if we need it later
- put " add 1 to i" & return after rst
- end if
- put " end if" & return after rst
- else if hasOptional then
- put " put " & paramIndex & " into i" & return after rst
- end if
- put true into firstOptional
- if hasOptional then
- put " repeat until i > the ParamCount" & return after rst
- put " put param(i) into x" & return after rst
- put " put " & quote & "," & quote & " after stmt" & return after rst
- put false into hasEnum
- repeat with i = 3 to count
- set cursor to busy
- put line i of paramInfo into x
- put item 4 of x into temp
- put (temp > 32767) into isOptional
- if isOptional then
- if firstOptional then
- put " " after rst
- put false into firstOptional
- else
- put " else " after rst
- end if
- put HTKeyWord(x) into thisKey
- put item 1 of x into thisName
- put StripSP(thisName) into noSpName
- put (char 5 to 8 of thisKey = "enum") into isEnum
- put "if x = " & quote & thisName & quote after rst
- if thisName <> noSpName then
- put " or x = " & quote & noSpName & quote after rst
- end if
- if isEnum and (item 2 of x <> noSpName) then
- put " or x = " & quote & item 2 of x & quote after rst
- end if
- put " then" & return after rst
- put " put quote & " & quote & thisKey & quote & " & quote & " & quote & "," & quote & " after stmt" & return after rst
- if isEnum then
- put true into hasEnum
- put EnumLines(enumInfo, 3, item 3 of x, "x", false) into temp
- if temp <> "" then
- put " put param(i+1) into x" & return after rst
- put temp after rst
- end if
- end if
- end if
- end repeat
- put " else" & return after rst
- put " put " & quote & "Param(" & quote & " & i & " & quote & ")," & quote & " after stmt" & return after rst
- put " end if" & return after rst
- if hasEnum then
- put " if last char of stmt = " & quote & "," & quote & " then" & return after rst
- put " put " & quote & "Param(" & quote & " & i+1 & " & quote & ")" & quote & " after stmt" & return after rst
- put " end if" & return after rst
- else
- put " put " & quote & "Param(" & quote & " & i+1 & " & quote & ")" & quote & " after stmt" & return after rst
- end if
- put " add 2 to i" & return after rst
- put " end repeat" & return after rst
- end if
- put " do stmt" & return after rst
- else -- all are required
- put header & return before rst
- put shortHeader & return after rst
- end if
- put " if the result is not empty then AEHandleError " & quote ¬
- & EventName & " error : " & quote & " & the Result" after rst
- if isFunc then
- put " else return it" after rst
- end if
- put return & "End " & EventName & return & return after rst
- return rst
- end EventSample
-
- function ClassSample elementList, classNameList, keyFormList
- put "" into rst
- -- we create the glue routine for the object specifiers
- put number of lines in elementList into elementCount
- put number of items in keyFormList into nameCount
- put number of lines in classNameList into classCount
- repeat with i = 1 to elementCount
- set cursor to busy
- put line i of elementList into x
- put item 1 of x into classID
- put number of items in x into formsPlus1
- repeat with j = 1 to classCount -- find the name
- set cursor to busy
- if classID = item 1 of line j of classNameList then
- put item 2 of line j of classNameList & "Object" into thisName
- put "function " & thisName & " form,data,container" & return after rst
- put "whose" into formChoice
- put " if form = " & quote & "whose" & quote & " then" & return after rst
- put " put " & quote & "test" & quote & " into form" & return after rst
- repeat with k = 2 to formsPlus1
- set cursor to busy
- put item k of x into nameForm
- put 2 into kk
- repeat while kk <= nameCount
- set cursor to busy
- if nameForm = item kk of keyFormList then
- put "|" & item (kk-1) of keyFormList after formChoice
- put " else if form = " & quote & item (kk-1) of keyFormList & quote & " then" & return after rst
- put " put " & quote & nameForm & quote & " into form" & return after rst
- exit repeat
- end if
- add 2 to kk
- end repeat
- end repeat
- put thisName & "(" after field "eventList"
- put length of field "eventList" + 1 into groupBegin
- put "{" & formChoice & "}" after field "eventList"
- put length of field "eventList" into groupEnd
- put ", data, container)" & return & return after field "eventList"
- set textstyle of char groupBegin to groupEnd of field "eventList" to group
- put " end if" & return after rst
- put " return AEObjectSpec(" & quote & classID & quote & ",form,data,container)" & return after rst
- put "end " & thisName & return & return after rst
- -- now do property
- put line j of classNameList into x
- put item 2 of x & "Property" into thisProp
- put number of items in x into k
- put 3 into kk
- put "function " & thisProp & " property,form,data,container" & return after rst
- put thisProp & "(" after field "eventList"
- put "{" into tempHeader
- repeat while kk < k
- set cursor to busy
- if kk = 3 then
- put " if" after rst
- else
- put " else if" after rst
- end if
- if kk <> 3 then
- put "|" after tempHeader
- end if
- put item kk of x after tempHeader
- put " property = " & quote & item kk of x & quote & " then" & return after rst
- put " put " & quote & item (kk+1) of x & quote & " into property" & return after rst
- add 2 to kk
- end repeat
- put " end if" & return after rst
- put length of field "eventList" + 1 into groupBegin
- put tempHeader & "}" after field "eventList"
- put length of field "eventList" into groupEnd
- put ", " after field "eventList"
- set textstyle of char groupBegin to groupEnd of field "eventList" to group
- put length of field "eventList" + 1 into groupBegin
- put "{" & formChoice & "}" after field "eventList"
- put length of field "eventList" into groupEnd
- put ", data, container)" & return & return after field "eventList"
- set textstyle of char groupBegin to groupEnd of field "eventList" to group
- put " return AEObjectSpec(" & quote & "prop" & quote & ", " ¬
- & quote & "prop" & quote & ", property, " & thisName ¬
- & "(form,data,container))" & return after rst
- put "end " & thisProp & return & return after rst
- exit repeat
- end if
- end repeat
- end repeat
- return rst
- end ClassSample
-
- function EnumLines enumInfo, indent, enumCode, varName, writeToVar
- repeat indent times
- set cursor to busy
- put " " after indentSpace
- end repeat
- put "" into rst
- put number of lines in enumInfo into enumCount
- repeat with enumIndex = 1 to enumCount
- set cursor to busy
- if item 1 of line enumIndex of enumInfo = enumCode then
- put line enumIndex of enumInfo into x
- put (number of items in x - 1) div 2 into n
- if n > 0 then
- -- now we go through the enum list and check each one
- put 2 into j
- repeat with i = 1 to n
- set cursor to busy
- if i = 1 then
- put indentSpace & "if" after rst
- else
- put indentSpace & "else if" after rst
- end if
- put space & varName & " = " & quote & item j of x & quote & " then" & return after rst
- if writeToVar then
- put indentSpace & " put " & quote & ResType(item j+1 of x) & quote & " into " & varName & return after rst
- else
- put indentSpace & " put quote & " & quote & ResType(item j+1 of x) & quote & " & quote after stmt" & return after rst
- end if
- add 2 to j
- end repeat
- put indentSpace & "end if" & return after rst
- end if -- if n > 0
- put enumCount+1 into enumIndex
- end if
- end repeat
- return rst
- end EnumLines
-
- function StripSP x, lowerCase
- put char 1 to 2 of x into y
- if (y = "#&") or (y = "#*") then
- delete char 1 to 2 of x -- it just means it is from AEUT
- end if
- put CharToNum(char 1 of x) into n
- if lowerCase = true then
- if (n >= 65) and (n <= 90) then
- put NumToChar(n+32) into char 1 of x
- end if
- else
- if (n >= 97) and (n <= 122) then
- put NumToChar(n-32) into char 1 of x
- end if
- end if
- repeat until i = 0
- set cursor to busy
- put offset(space, x) into i
- if i > 0 then
- put CharToNum(char (i+1) of x) into n
- if (n >= 97) and (n <= 122) then
- put NumToChar(n-32) into char (i+1) of x
- end if
- delete char i of x
- end if
- end repeat
- return x
- end StripSP
-
- function HTKeyWord info
- put ((item 4 of info) div 8192) mod 4 into temp
- if temp > 1 then
- put "list" into thisType
- else if temp = 1 then
- put "enum" into thisType
- else
- put ResType(item 3 of info) into thisType
- end if
- -- if it is a special type, we need to append type after keyword
- if (thisType = "TEXT") OR (thisType = "obj ") OR (thisType = "list") or (thisType = "null") then
- return item 2 of info
- else
- return ResType(item 2 of info) & ThisType
- end if
- end HTKeyWord
-
- function ResType x
- return char 1 to 4 of (x & " ")
- end ResType
-
- On HyperTalkTemplate eventName, eventComment, paramInfo, enumInfo
- put quote & "----" & quote into dash
- put (item 3 of line 1 of paramInfo <> "null") into isFunc
- put 0 into paramIndex
- put number of lines in paramInfo into n
- -- either return the template or which parameter is being clicked
- put "" into paramComment
- put "AE" & StripSP(eventName) into template
- if isFunc then
- put " (" after template
- else
- put space after template
- end if
- put "" into paramDelim
- put true into firstTime -- no comma before first param
- put 1 into optionEnd -- we loop twice, once for required once for optional
- -- we loop through it twice, on time for required, one for opt
- repeat with option = 0 to optionEnd
- set cursor to busy
- put (option = 1) into wantOptional
- repeat with index = 2 to n
- set cursor to busy
- put line index of paramInfo into y
- put item 4 of y into temp
- put (temp > 32767) into isOptional
- if (isOptional = wantOptional) then
- put temp div 8192 into temp
- put (temp mod 2 = 1) into isEnum
- put true into useIt
- if index = 2 then
- if item 3 of y = "null" then put false into useIt
- put "directParam" into item 1 of y
- put "----" into item 2 of y
- end if
- if useIt then
- add 1 to paramIndex
- if useIt then
- if item 5 of y <> "" then
- put y into thisComment
- delete item 1 to 4 of thisComment
- put "-- " & item 1 of y & ": " & thisComment & return after paramComment
- end if
- if isOptional then
- put " [" after template
- put "o," & length of template & "," after paramDelim
- else
- put space after template
- end if
- if (index <> 2) and isOptional then
- if firstTime then
- put false into firstTime
- else
- put "," after template
- end if
- put item 1 of y into thisKey
- put quote & thisKey & quote after template
- end if
- if firstTime then
- put false into firstTime
- else
- put "," after template
- end if
- if isOptional then
- if item 3 of y = "true" then
- put "true" after template
- else if isEnum then
- put EnumOption(enumInfo,item 3 of y) after template
- else if (item 1 of y = "Class") and (item 3 of y = "type") then
- put ClassList() after template
- else
- put "some" & item 3 of y after template
- end if
- put "]" after template
- put (length of template) & "," after paramDelim
- else
- if isEnum then
- put "r," & length of template + 1 & "," after paramDelim
- put EnumOption(enumInfo,item 3 of y) after template
- put (length of template) & "," after paramDelim
- else if (item 1 of y = "Class") and (item 3 of y = "type") then
- put "r," & length of template + 1 & "," after paramDelim
- put ClassList() after template
- put (length of template) & "," after paramDelim
- else
- put item 1 of y after template
- end if
- end if
- end if
- end if -- useit
- end if -- the right kind of option
- end repeat
- end repeat
- if isFunc then
- put " )" after template
- end if
- put return after template
- if eventComment <> "" then
- put "-- " & eventComment & return after template
- end if
- put paramComment & return after template
- put length of field "eventList" into orgSize
- put template after field "eventList"
- put 1 into i
- put number of items in paramDelim into n
- repeat until i >= n
- set cursor to busy
- if item i of paramDelim = "o" then
- put "italic,group" into styl
- else
- put "group" into styl
- end if
- set textstyle of char (orgSize + item i+1 of paramDelim) to ¬
- (orgSize + item i+2 of paramDelim) of field "eventList" to styl
- add 3 to i
- end repeat
- end HyperTalkTemplate
-
- function EnumOption enumInfo,enumeration
- put "" into theList
- put number of lines in enumInfo into enumCount
- repeat with enumIndex = 1 to enumCount
- set cursor to busy
- if item 1 of line enumIndex of enumInfo = enumeration then
- put line enumIndex of enumInfo into x
- put (number of items in x - 1) div 2 into n
- if n > 0 then
- -- now we go through the enum list and check each one
- put "{" & item 2 of x into theList
- put 4 into j
- repeat with i = 2 to n
- set cursor to busy
- put "|" & item j of x after theList
- add 2 to j
- end repeat
- put "}" after theList
- end if -- if n > 0
- return theList
- end if
- end repeat
- end EnumOption
-
- function ClassList
- put field "classNameList" into classNameList
- put number of lines in classNameList into n
- put "{" into x
- repeat with i = 1 to n
- if i <> 1 then put "|" after x
- put item 2 of line i of classNameList after x
- end repeat
- return x & "}"
- end ClassList
-
- function MakePickClassName classNameList
- put "function PickClassName className" & return into rst
- if classNameList = "" then
- put "return className" & return after rst
- else
- put number of lines in classNameList into n
- repeat with i = 1 to n
- put "if className = " & quote & item 2 of line i of classNameList ¬
- & quote & " then" & return & "return " & quote ¬
- & item 1 of line i of classNameList & quote & return & "else " after rst
- end repeat
- put return & "return className" & return & "end if" & return into last char of rst
- end if
- return rst & "end PickClassName" & return & return
- end MakePickClassName</script>
- </part>
- <part>
- <id>2</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>409</left>
- <top>23</top>
- <right>485</right>
- <bottom>42</bottom>
- </rect>
- <style>shadow</style>
- <showName> <true /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>center</textAlign>
- <font>Helvetica</font>
- <textSize>10</textSize>
- <textStyle>bold</textStyle>
- <name>Launch App</name>
- <script>On MouseWithin
- ShowBalloon "Click here to launch this application."
- End MouseWithin
-
- on mouseUp
- HMRemoveBalloon
- open field "targetApp"
- end mouseUp
-
- on xmouseUp
- if the optionKey is down then
- open field "targetApp"
- else
- answer program "send to which program"
- if it <> "" then
- Set the itemDelimiter to ":"
- put it into x
- delete last item of x
- put the address into y
- delete last item of y
- if x = y then
- delete item 1 to 2 of it
- end if
- put it into x
- Set the itemDelimiter to ","
- StopTargeting
- put x into field "targetApp"
- AEStartTargeting x,"NoLaunch"
- else if the optionKey is down then
- open field "targetApp"
- end if
- end if
- end xmouseUp</script>
- </part>
- <part>
- <id>3</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>8</left>
- <top>25</top>
- <right>289</right>
- <bottom>46</bottom>
- </rect>
- <style>transparent</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Helvetica</font>
- <textSize>18</textSize>
- <textStyle>bold</textStyle>
- <textHeight>24</textHeight>
- <name>targetApp</name>
- <script>-- On MouseWithin
- -- ShowBalloon "The Apple Events routines displayed on this card is for this application."
- -- End MouseWithin
- </script>
- </part>
- <part>
- <id>5</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <false /> </lockText>
- <rect>
- <left>8</left>
- <top>256</top>
- <right>461</right>
- <bottom>337</bottom>
- </rect>
- <style>scrolling</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Monaco</font>
- <textSize>9</textSize>
- <textStyle>plain</textStyle>
- <textHeight>12</textHeight>
- <name>myMsgBox</name>
- <script>On MouseWithin
- put CharToNum(char 1 of me) into x
- if ((char 1 of me) = (char 6 of me)) and ((x = 174) or (x = 190)) then
- ShowBalloon me
- else
- ShowBalloon "Apple Events commands can be sent from this field. Click the " & quote & "Do It" ¬
- & quote & "button to the right to execute the content of this field."
- end if
- End MouseWithin
- </script>
- </part>
- <part>
- <id>6</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>466</left>
- <top>321</top>
- <right>509</right>
- <bottom>340</bottom>
- </rect>
- <style>shadow</style>
- <showName> <true /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <false /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>center</textAlign>
- <font>Helvetica</font>
- <textSize>12</textSize>
- <textStyle>bold</textStyle>
- <name>obj</name>
- <script>on MouseUp
- if short name of target = "Obj" then
- set name of target to "Cmd"
- Hide field "eventList"
- StartChunkExpr
- else
- if the optionKey is down then
- StartChunkExpr
- else
- set name of target to "Obj"
- put "1. Click parameters to select them. 2. Then click handler names to copy them to the messages field below:" into field "operation"
- Show field "eventList"
- end if
- end if
- HMRemoveBalloon
- end mouseUp
-
- on mouseEnter
- global myMsgBoxSelection
- put the selectedChunk into myMsgBoxSelection
- end mouseEnter
-
- On MouseWithin
- if short name of target = "Obj" then
- ShowBalloon "Hit this button to generate an object specifier using graphical user interface"
- else
- ShowBalloon "Hit this button to list the commands you can send, or hit the button with the option key down to restart the object specification"
- end if
- End MouseWithin
- </script>
- </part>
- <part>
- <id>8</id>
- <type>field</type>
- <visible> <false /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <false /> </lockText>
- <rect>
- <left>8</left>
- <top>245</top>
- <right>509</right>
- <bottom>276</bottom>
- </rect>
- <style>scrolling</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Geneva</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <textHeight>16</textHeight>
- <name>chunkExp</name>
- <script>on MouseWithin
- ShowBalloon "Don't worry about this, it will not be shown in the final version."
- end MouseWithin
- </script>
- </part>
- <part>
- <id>9</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>11</left>
- <top>48</top>
- <right>508</right>
- <bottom>63</bottom>
- </rect>
- <style>transparent</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Geneva</font>
- <textSize>9</textSize>
- <textStyle>plain</textStyle>
- <textHeight>12</textHeight>
- <name>operation</name>
- <script></script>
- </part>
- <part>
- <id>10</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <true /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>9</left>
- <top>62</top>
- <right>507</right>
- <bottom>241</bottom>
- </rect>
- <style>scrolling</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Geneva</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <textHeight>16</textHeight>
- <name>pickList</name>
- <script>on MouseWithin
- put last item of line 1 of field "cardState" into curState
- if (curState = "pickElem") then
- ShowBalloon "Pick a property or element from the container."
- else if (curState = "pickObj1") then
- ShowBalloon "You are picking an object or property to be used in comparision."
- else if (curState = "pickObj2") then
- ShowBalloon "You are picking another object, property or constant for comparision with the first one."
- else if curState = "pickKeyForm" then
- ShowBalloon "There are many way you can pick an element, please identify one."
- else if curState = "pickCmpr" then
- ShowBalloon "How should the last object compare with the next one?"
- end if
- end MouseWithin
-
- on MouseUp
- HMRemoveBalloon
- put value of the clickLine into select
- if select = "" then exit MouseUp
- put field "operation" into operation
- put last item of line 1 of field "cardState" into curState
- if (curState = "pickElem") or (curState = "pickObj1") or (curState = "pickObj2") then
- put (last word of select = "property") into isProperty
- put last item of line 2 of field "cardState" into containerCode
- if (select = "constant") and (curState = "pickObj2") then
- ask "compare the value to"
- put "cnstcnst(" & it & ")" after field "chunkExp"
- ChunkComplete
- else if isProperty then
- if curState = "pickObj1" then
- put " " & select after field "operation"
- end if
- delete last word of select
- put PropNameToCode(containerCode, select) & "prop" after field "chunkExp"
- ChunkComplete
- else if last word of select = "itself" then
- if curState = "pickObj1" then
- put " " & select after field "operation"
- end if
- Delete last char of field "chunkExp"
- ChunkComplete
- else
- put ClassNameToCode(select) into classCode
- put classCode after field "chunkExp"
- put classCode into last item of line 2 of field "cardState"
- put "Which" && select into field "operation"
- put KeyFormList(containerCode, classCode) into field "pickList"
- put "pickKeyForm" into last item of line 1 of field "cardState"
- end if
- else if curState = "pickKeyForm" then
- put last item of line 2 of field "cardState" into classCode
- if select = "whose" then
- put "test(" after field "chunkExp"
- put "," & classCode after line 2 of field "cardState"
- MakePickList classCode,"pickObj1"
- else
- ask operation && select
- put KeyFormNameToCode(select) & "(" & it & ")." after field "chunkExp"
- delete last item of line 1 of field "cardState"
- MakePickList classCode,"pickElem"
- end if
- else if curState = "pickCmpr" then
- put " " & select after field "operation"
- put select & "," after field "chunkExp"
- MakePickList last item of line 2 of field "cardState", "pickObj2"
- end if
- end MouseUp
- </script>
- </part>
- <part>
- <id>7</id>
- <type>field</type>
- <visible> <false /> </visible>
- <dontWrap> <true /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <false /> </lockText>
- <rect>
- <left>155</left>
- <top>214</top>
- <right>509</right>
- <bottom>245</bottom>
- </rect>
- <style>scrolling</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Geneva</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <textHeight>16</textHeight>
- <name>classNameList</name>
- <script>on MouseWithin
- ShowBalloon "Don't worry about this, it will not be shown in the final version."
- end MouseWithin
- </script>
- </part>
- <part>
- <id>12</id>
- <type>field</type>
- <visible> <false /> </visible>
- <dontWrap> <true /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <false /> </lockText>
- <rect>
- <left>154</left>
- <top>180</top>
- <right>507</right>
- <bottom>213</bottom>
- </rect>
- <style>scrolling</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Geneva</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <textHeight>16</textHeight>
- <name>hierarchyList</name>
- <script>on MouseWithin
- ShowBalloon "Don't worry about this, it will not be shown in the final version."
- end MouseWithin
- </script>
- </part>
- <part>
- <id>11</id>
- <type>field</type>
- <visible> <false /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>8</left>
- <top>84</top>
- <right>137</right>
- <bottom>180</bottom>
- </rect>
- <style>scrolling</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Geneva</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <textHeight>16</textHeight>
- <name>cardState</name>
- <script>on MouseWithin
- ShowBalloon "Don't worry about this, it will not be shown in the final version."
- end MouseWithin
- </script>
- </part>
- <part>
- <id>14</id>
- <type>field</type>
- <visible> <false /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <false /> </lockText>
- <rect>
- <left>8</left>
- <top>180</top>
- <right>155</right>
- <bottom>213</bottom>
- </rect>
- <style>rectangle</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Geneva</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <textHeight>16</textHeight>
- <name>keyFormList</name>
- <script>on MouseWithin
- ShowBalloon "Don't worry about this, it will not be shown in the final version."
- end MouseWithin
- </script>
- </part>
- <part>
- <id>13</id>
- <type>field</type>
- <visible> <false /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <false /> </lockText>
- <rect>
- <left>8</left>
- <top>212</top>
- <right>155</right>
- <bottom>245</bottom>
- </rect>
- <style>rectangle</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Geneva</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <textHeight>16</textHeight>
- <name>compareList</name>
- <script>on MouseWithin
- ShowBalloon "Don't worry about this, it will not be shown in the final version."
- end MouseWithin
- </script>
- </part>
- <part>
- <id>4</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <true /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>8</left>
- <top>62</top>
- <right>507</right>
- <bottom>241</bottom>
- </rect>
- <style>scrolling</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Monaco</font>
- <textSize>9</textSize>
- <textStyle>plain</textStyle>
- <textHeight>12</textHeight>
- <name>EventList</name>
- <script>on mouseEnter
- global myMsgBoxSelection
- put the selectedChunk into myMsgBoxSelection
- --idleCursor(128)
- end mouseEnter
-
- --on mouseLeave
- --idleCursor(hand)
- --end mouseLeave
-
- on mouseUp
- set cursor to watch
- put the clickLine into x
- put word 2 of x into theLine
- put value of x into y
- repeat while char 1 of y = "-"
- subtract 1 from theLine
- put theLine into word 2 of x
- put value of x into y
- end repeat
- put the clickChunk into cc
- put the clickText into cv
- put char 1 of cv into beginChar
- if (beginChar = "[") or (beginChar = "{") then
- if italic is in the textstyle of cc then
- put Offset("{", cv) into enumDelim
- if enumDelim > 0 then
- set lockText of me to false
- click at the clickLoc
- click at the clickLoc
- put the selectedChunk into sc
- set lockText of me to true
- put (((word 2 of sc) - (word 2 of cc)) >= enumDelim) into enumChosen
- if enumChosen then
- put cc into orgCc
- end if
- set textStyle of cc to "plain"
- -- we have a enum, we need to break into 2 groups
- put word 4 of cc into paramEnd
- put word 2 of cc + enumDelim - 3 into word 4 of cc
- set textstyle of cc to "group"
- put (word 4 of cc) + 2 into word 2 of cc
- put paramEnd into word 4 of cc
- set textStyle of cc to "group"
- if enumChosen then
- DoEnumStuff orgCc,sc,cv
- end if
- else -- just enable the whole group
- set textstyle of cc to "plain,group"
- end if
- else if beginChar = "{" then
- -- we have enum choices here
- set lockText of me to false
- click at the clickLoc
- click at the clickLoc
- put the selectedChunk into sc
- set lockText of me to true
- set textstyle of cc to "plain,group"
- DoEnumStuff cc,sc,cv
- else if char (word 4 of cc) of me = "]" then
- set textstyle of cc to "italic,group"
- else -- we need to include the enum again
- put Offset("]", char (word 4 of cc) to (word 2 of cc + 500) of me) into enumDelim
- put (word 4 of cc) + enumDelim - 1 into word 4 of cc
- set textstyle of cc to "italic,group"
- end if
- else if y <> "" then
- put 0 into deleteCount
- put 1 into beginOpt
- repeat until (beginOpt = 0) and (beginEnum = 0)
- -- search for the next optional param
- put offset ("[", y) into beginOpt
- put offset ("{", y) into beginEnum
- if (beginOpt > 0) and ((beginEnum = 0) or (beginOpt < beginEnum)) then
- delete char beginOpt of y
- add 1 to deleteCount
- put (italic is in textstyle of char (beginOpt + deleteCount) of line theLine of me) into dontWant
- put offset ("]", y) into endOpt
- if endOpt > 0 then
- if dontWant then -- if italic we don't want it
- if char endOpt+1 of y = " " then add 1 to endOpt
- delete char beginOpt to endOpt of y
- add (endOpt - beginOpt + 1) to deleteCount
- else
- put false into enumChosen -- we want it, but check for enum first
- if char beginOpt of y = "," then add 1 to beginOpt
- add Offset(",", char beginOpt to endOpt of y) to beginOpt -- skip keyword
- if "{" is in (char beginOpt to endOpt of y) then -- we have enum
- put beginOpt into enumOffset -- first enum start here
- repeat until enumOffset >= endOpt
- -- determine extent of enum
- put offset("|", char enumOffset to endOpt of y) into enumEnd
- if enumEnd > 0 then
- put enumEnd + enumOffset - 2 into enumEnd
- else
- put endOpt-2 into enumEnd
- end if
- -- enum is chosen if it is bold
- if bold is in (textstyle of char (enumOffset + deleteCount) of line theLine of me) then
- put true into enumChosen
- exit repeat
- else
- put enumEnd + 2 into enumOffset
- end if
- end repeat
- end if
- if enumChosen then
- -- we just pick the chosen one
- put quote into char beginOpt of y
- put quote into char endOpt of y
- put char enumOffset to enumEnd of y into char beginOpt+1 to endOpt-1 of y
- add (endOpt - beginOpt - enumEnd + enumOffset - 2) to deleteCount
- else
- delete char endOpt of y
- add 1 to deleteCount
- end if
- end if
- end if
- else if beginEnum > 0 then
- put false into enumChosen -- we want it, but check for enum first
- put offset ("}", y) into endOpt
- put beginEnum + 1 into enumOffset -- first enum start here
- repeat until enumOffset >= endOpt
- -- determine extent of enum
- put offset("|", char enumOffset to endOpt of y) into enumEnd
- if enumEnd > 0 then
- put enumEnd + enumOffset - 2 into enumEnd
- else
- put endOpt-1 into enumEnd
- end if
- -- enum is chosen if it is bold
- if bold is in (textstyle of char (enumOffset + deleteCount) of line theLine of me) then
- put true into enumChosen
- exit repeat
- else
- put enumEnd + 2 into enumOffset
- end if
- end repeat
- if enumChosen then
- -- we just pick the chosen one
- put quote into char beginEnum of y
- put quote into char endOpt of y
- put char enumOffset to enumEnd of y into char beginEnum+1 to endOpt-1 of y
- add (endOpt - beginEnum - enumEnd + enumOffset - 2) to deleteCount
- else
- put quote into char beginEnum of y
- put quote into char endOpt of y
- end if
- end if
- end repeat
- if char 1 of word 2 of y = "," then
- delete char 1 of word 2 of y
- else if char 1 of word 2 of y = "(" then
- if char 1 of word 3 of y = "," then
- delete char 1 of word 3 of y
- end if
- end if
- PutMyMsgBox y
- end if
- end mouseUp
-
- On DoEnumStuff cc,sc,cv
- put (word 2 of sc) - (word 2 of cc) + 1 into ccBegin
- put offset("|", char ccBegin to 9999 of cv) into ccEnd
- -- scan forward for "|" or end of enum
- if ccEnd > 0 then -- set the chunk to |
- put (word 2 of sc) + ccEnd - 2 into word 4 of sc
- else -- no more "|", go all the way }
- put (word 2 of sc) + offset("}", char ccBegin to 9999 of cv) - 2 into word 4 of sc
- end if
- -- scan backward for begin of enum
- put word 2 of sc into orgVal
- repeat
- subtract 1 from ccBegin
- if (char ccBegin of cv = "{") or (char ccBegin of cv = "|") then
- put orgVal into word 2 of sc
- exit repeat
- else
- subtract 1 from orgVal
- end if
- end repeat
- set textstyle of sc to "bold,group"
- End DoEnumStuff
-
- On MouseWithin
- ShowBalloon "This is a list of the Apple Event glue routines for this application." && ¬
- "Clicking on a command will move it into the messages field below it."
- end MouseWithin</script>
- </part>
- <part>
- <id>15</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>466</left>
- <top>268</top>
- <right>509</right>
- <bottom>283</bottom>
- </rect>
- <style>shadow</style>
- <showName> <true /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <false /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>center</textAlign>
- <font>Helvetica</font>
- <textSize>12</textSize>
- <textStyle>bold</textStyle>
- <name>Clear</name>
- <script>on mouseUp
- if visible of bkgnd field "myResult" then
- if IsTempDesc(field "myResult") then
- AEDisposeDesc(field "myResult")
- end if
- put "" into field "myResult"
- else
- if IsTempDesc(field "myMsgBox") then
- AEDisposeDesc(field "myMsgBox")
- end if
- put "" into field "myMsgBox"
- end if
- end mouseUp
-
- On MouseWithin
- if visible of bkgnd field "myMsgBox" then
- ShowBalloon "Click this button to clear contents of the field to the left."
- else
- ShowBalloon "Click this button to clear contents of the results field to the left."
- end if
- End MouseWithin
- </script>
- </part>
- <part>
- <id>16</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>466</left>
- <top>286</top>
- <right>509</right>
- <bottom>301</bottom>
- </rect>
- <style>shadow</style>
- <showName> <true /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <false /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>center</textAlign>
- <font>Helvetica</font>
- <textSize>12</textSize>
- <textStyle>bold</textStyle>
- <name>Do It</name>
- <script>on mouseUp
- if the short name of me = "Do It" then
- -- note we use very long variable name here
- -- we do this to aviod conflict with the same name in msg box
- put field "myMsgBox" into theScriptFromMyMsgBox
- if IsTempDesc(field "myResult") then
- AEDisposeDesc(field "myResult")
- end if
- put "" into field "myResult"
- ShowResult
- repeat with curLineInScriptFromMyMsgBox = 1 to number of lines in theScriptFromMyMsgBox
- put line curLineInScriptFromMyMsgBox of theScriptFromMyMsgBox into curStatementFromMsgBox
- if (word 1 of curStatementFromMsgBox contains "(") ¬
- or (char 1 of word 2 of curStatementFromMsgBox = "(") then
- -- it is a function
- if IsTempDesc(field "myResult") then
- AEDisposeDesc(field "myResult")
- end if
- put value of curStatementFromMsgBox into field "myResult"
- else
- do curStatementFromMsgBox
- end if
- end repeat
- else
- ShowScript
- end if
- end mouseUp
-
- On MouseWithin
- if the short name of me = "Do It" then
- ShowBalloon "Click this button to execute the messages field to the left."
- else
- ShowBalloon "Click this button to display the special messages field."
- end if
- End MouseWithin
- </script>
- </part>
- <part>
- <id>17</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>289</left>
- <top>24</top>
- <right>306</right>
- <bottom>40</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>15420</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name></name>
- <script>on MouseWithin
- ShowBalloon "Click here to go to the previous application card."
- end MouseWithin
-
- on mouseUp
- visual wipe right
- go previous card of this background
- end mouseUp</script>
- </part>
- <part>
- <id>18</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>309</left>
- <top>24</top>
- <right>324</right>
- <bottom>40</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>16560</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name></name>
- <script>on MouseWithin
- ShowBalloon "Click here to go to the next application card."
- end MouseWithin
-
- on mouseUp
- visual wipe left
- go next card of this background
- end mouseUp</script>
- </part>
- <part>
- <id>19</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>488</left>
- <top>23</top>
- <right>508</right>
- <bottom>41</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>6720</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name></name>
- <script>on MouseWithin
- ShowBalloon "Click here to go back to the applications list card."
- end MouseWithin
-
- on mouseUp
- HMRemoveBalloon
- visual dissolve
- go to card id 8694
- end mouseUp
-
- </script>
- </part>
- <part>
- <id>21</id>
- <type>field</type>
- <visible> <false /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <false /> </lockText>
- <rect>
- <left>8</left>
- <top>256</top>
- <right>461</right>
- <bottom>337</bottom>
- </rect>
- <style>scrolling</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Monaco</font>
- <textSize>9</textSize>
- <textStyle>plain</textStyle>
- <textHeight>12</textHeight>
- <name>myResult</name>
- <script>On MouseWithin
- put CharToNum(char 1 of me) into x
- if ((char 1 of me) = (char 6 of me)) and ((x = 174) or (x = 190)) then
- ShowBalloon me
- else
- ShowBalloon "this is the result of executing your script."
- end if
- End MouseWithin
- </script>
- </part>
- <part>
- <id>22</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>466</left>
- <top>304</top>
- <right>509</right>
- <bottom>319</bottom>
- </rect>
- <style>shadow</style>
- <showName> <true /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <false /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>center</textAlign>
- <font>Helvetica</font>
- <textSize>12</textSize>
- <textStyle>bold</textStyle>
- <name>Save</name>
- <script>on mouseUp
- if there is a card button "Test" then
- put script of card button "Test" into btnScript
- -- save the message box
- if field "myMsgBox" = "" then
- answer "There is no script to save"
- else
- put AllHandlerName(btnScript) into handlerNameList
- ask "Please name this handler. (Enter '?' to save the script to an existing handler.)" with "test" & the ticks
- put it into handlerName
- put "Cancel" into action
- put 1 into i
- repeat until i = 0
- put Offset(space, handlerName) into i
- if i > 0 then delete char i of handlerName
- end repeat
- if handlerName = "" then
- else if handlerName = "?" then
- put ShowList(FirstItemOfEachLine(handlerNameList), "Save to which existing handler?", false, ¬
- true, "Append,Replace,Cancel", 0) into temp
- put line 1 of temp into action
- if action <> cancel then
- put line 2 of temp into i
- put item 1 of line i of handlerNameList into handlerName
- put item 2 of line i of handlerNameList into beginHandler
- put item 3 of line i of handlerNameList into endHandler
- end if
- else
- put Search(handlerNameList, handlerName, true) into x
- if x = "" then
- put "new" into action
- else
- answer "Handler already exists, what should we do?" with "Cancel" or "Replace" or "Append"
- put it into action
- if action <> "Cancel" then
- put item 1 of x into i
- put item 2 of line i of handlerNameList into beginHandler
- put item 3 of line i of handlerNameList into endHandler
- end if
- end if
- end if
- if action = "new" then
- put return & "On" && handlerName & return & ScriptFromMsgBox() & return after btnScript
- put "End" && handlerName & return after btnScript
- else if endHandler <> 0 then
- if action = "Replace" then
- put ScriptFromMsgBox() into line beginHandler to endHandler of btnScript
- else if action = "Append" then
- put return & ScriptFromMsgBox() after line endHandler of btnScript
- end if
- end if
- end if
- if action <> "cancel" then
- Set the script of card button "test" to btnScript
- end if
- else
- answer "You do not have a Test button" with "Cancel"
- end if
- end mouseUp
-
- Function ScriptFromMsgBox
- put field "myMsgBox" into myMsgBox
- put number of lines in myMsgBox into n
- put 0 into lastFunc
- repeat with i = 1 to n
- put line i of myMsgBox into x
- if (word 1 of x contains "(") or (char 1 of word 2 of x = "(") then
- put i into lastFunc
- end if
- end repeat
- repeat with i = 1 to n
- put line i of myMsgBox into x
- if (word 1 of x contains "(") or (char 1 of word 2 of x = "(") then
- if i <> lastFunc then
- put "AEDisposeDesc " before line i of myMsgBox
- else
- put "put " before line i of myMsgBox
- end if
- end if
- end repeat
- if last char of myMsgBox = return then
- delete last char of myMsgBox
- end if
- return myMsgBox
- End ScriptFromMsgBox
-
- On MouseWithin
- ShowBalloon "Clicking here put the contents of messages field into the script of the button 'Test.'"
- End MouseWithin
- </script>
- </part>
- <part>
- <id>24</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>11</left>
- <top>242</top>
- <right>137</right>
- <bottom>257</bottom>
- </rect>
- <style>transparent</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Geneva</font>
- <textSize>9</textSize>
- <textStyle>plain</textStyle>
- <textHeight>12</textHeight>
- <name>lowerFieldTitle</name>
- <script></script>
- </part>
- <name>AppCards</name>
- <script>on openStack
- if the screenRect is "0,0,512,342" then set the loc of cd window to "0,0"
- if the userLevel < 5 then set the userLevel to 5
- if the systemVersion < "7.0" then -- Systems < 7.0 don't support Apple Events.
- answer "You must be running System 7.0 or later to send Apple Events™"¬
- &&"from this stack."
- end if
- if the version < "2.1" then -- HyperCard < 2.1 doesn't support Apple Events.
- answer "HyperCard version 2.1 or later is required to use this stack."
- end if
- end openStack
-
- on closeStack
- if the freesize of this stack > 32768 then
- get there is a menuItem "Compact Stack" of menu "File"
- if it then doMenu "Compact Stack"
- end if
- pass closeStack
- end closeStack
-
- on resumeStack
- if the userLevel < 5 then set the userLevel to 5
- end resumeStack
-
- on go
- HMRemoveBalloon -- Removes any vestigal balloons which may have
- pass go -- left from the "ShowBalloon" XCMD.
- end go
-
- on NewCard
- set lockscreen to true
- put "On MouseUp" & return & "PickMouseUpScript" & return ¬
- & "end MouseUp" & return ¬
- & "On MouseWithin" & return & "ShowBalloon " & quote ¬
- & "Click here to execute, edit or export a test script:" & quote & return ¬
- & "end MouseWithin" & return after btnScript
- doMenu "new button"
- get "cd btn id" && the id of cd btn "new button"
- set the name of it to "Test"
- set the textFont of it to "Helvetica"
- set the textStyle of it to "bold"
- set the rect of it to "466,250,509,265"
- set the style of it to shadow
- set the autoHilite of it to true
- set the script of it to btnScript
- choose browse tool
- set lockscreen to false
- end NewCard
-
- On CmdOrObjButton
- if field "classNameList" <> "" then
- if short name of bkgnd button id 6 = "cmd" then
- set name of bkgnd button id 6 to "obj"
- end if
- show bkgnd button id 6
- else
- hide bkgnd button id 6
- end if
- End CmdOrObjButton
-
- On OpenCard
- ShowScript
- Show field "eventList"
- CmdOrObjButton
- AEStartTargeting field "targetApp","NoLaunch"
- if field "targetApp" = "" then Click At loc of bkgnd button "Read Aete"
- pass OpenCard
- End OpenCard
-
- On CloseCard
- AEStopTargeting
- if IsTempDesc(field "myMsgBox") then
- AEDisposeDesc(field "myMsgBox")
- put "" into field "myMsgBox"
- end if
- if field "targetApp" = "" then
- put "Unknown Application" && Random(1000) into field "targetApp"
- end if
- put short name of this card into x
- if x <> field "targetApp" then
- set name of this card to field "targetApp"
- MakeNameList
- end if
- pass CloseCard
- End CloseCard
-
- On CloseStack
- global editAEScript
- put "" into editAEScript
- pass closeStack
- End CloseStack
-
- -- on EnterKey
- -- click at loc of bkgnd button id 16
- -- end EnterKey
-
- on ShowScript
- put "Messages:" into fld "lowerFieldTitle"
- Show Field "myMsgBox"
- Hide Field "myResult"
- Show bkgnd button "Save"
- set name of bkgnd button id 16 to "Do It"
- end ShowScript
-
- on ShowResult
- put "Results:" into fld "lowerFieldTitle"
- Show Field "myResult"
- Hide bkgnd button "Save"
- set name of bkgnd button id 16 to "Script"
- end ShowResult
-
- on PutMyMsgBox statement
- global myMsgBoxSelection
- put myMsgBoxSelection into x
- delete word 1 to 4 of x
- if x = "of bkgnd field 2" then
- put "put statement into " before myMsgBoxSelection
- do myMsgBoxSelection
- else
- if field "myMsgBox" <> "" then
- put return before statement
- end if
- put statement after field "myMsgBox"
- end if
- put "" into myMsgBoxSelection
- if field "myMsgBox" is not visible then ShowScript
- end PutMyMsgBox
-
- On MakeNameList
- put "" into nameList
- put number of cards in this bg into n
- repeat with i = 1 to n
- get the short name of card i of this bg
- put it & return after nameList
- end repeat
- put nameList into card field "appList" of card "appList"
- End MakeNameList
-
- on deletecard
- pass deletecard
- end deletecard
-
- On StartChunkExpr
- put "" into field "chunkExp"
- put "done" into field "cardState"
- MakePickList "capp","pickElem"
- End StartChunkExpr
-
- Function ClassCodeToName classCode
- put field "classNameList" into classNameList
- put number of lines in classNameList into n
- repeat with i = 1 to n
- if classCode = item 1 of line i of classNameList then
- return item 2 of line i of classNameList
- end if
- end repeat
- if classCode = "capp" then return "application"
- return "?" & classCode & "?"
- End ClassCodeToName
-
- Function ClassNameToCode className
- put field "classNameList" into classNameList
- put number of lines in classNameList into n
- repeat with i = 1 to n
- if className = item 2 of line i of classNameList then
- return item 1 of line i of classNameList
- end if
- end repeat
- if className = "application" then return "capp"
- return "????"
- End ClassNameToCode
-
- Function KeyFormNameToCode keyFormName
- put field "keyFormList" into keyFormList
- put number of items in keyFormList into n
- put 1 into i
- repeat while i <= n
- if item i of keyFormList = keyFormName then
- return item i+1 of keyFormList
- end if
- add 2 to i
- end repeat
- return keyFormName
- end KeyFormNameToCode
-
- Function PropertyList classCode
- put "" into propList
- put field "classNameList" into classNameList
- put number of lines in classNameList into n
- repeat with i = 1 to n
- if item 1 of line i of classNameList = classCode then
- put line i of classNameList into classInfo
- put (number of items in classInfo) div 2 - 1 into propCount
- put 3 into j
- repeat propCount times
- put item j of classInfo && "property" & return after propList
- add 2 to j
- end repeat
- exit repeat
- end if
- end repeat
- return propList
- End PropertyList
-
- Function ElementList classCode
- put field "hierarchyList" into hierarchyList
- put "" into elemList
- put number of lines in hierarchyList into n
- if classCode <> "capp" then
- put ClassCodeToName(classCode) && "itself" & return after elemList
- end if
- put number of lines in hierarchyList into n
- repeat with i = 1 to n
- if item 1 of line i of hierarchyList = classCode then
- put line i of hierarchyList into itemList
- put number of items in itemList into itemCount
- repeat with j = 2 to itemCount
- put ClassCodeToName(char 1 to 4 of item j of itemList) & return after elemList
- end repeat
- exit repeat
- end if
- end repeat
- return elemList
- End ElementList
-
- Function KeyFormList containerClass, elementClass
- put field "hierarchyList" into hierarchyList
- put field "KeyFormList" into keyFormName
- put number of lines in hierarchyList into n
- put number of items in keyFormName into keyNameCount
- repeat with i = 1 to n
- if containerClass = item 1 of line i of hierarchyList then
- put line i of hierarchyList into classInfo
- put number of items in classInfo into m
- repeat with j = 2 to m
- if char 1 to 4 of item j of classInfo = elementClass then
- put char 5 to 10000 of item j of classInfo into x
- if field "compareList" <> "" then put "whose" & return into rst
- repeat while x <> ""
- put char 1 to 4 of x into thisKey
- put 2 into k
- repeat while k <= keyNameCount
- if item k of keyFormName = thisKey then
- put item k-1 of keyFormName into thisKey
- exit repeat
- end if
- add 2 to k
- end repeat
- put thisKey & return after rst
- delete char 1 to 4 of x
- end repeat
- return rst
- end if
- end repeat
- end if
- end repeat
- return ""
- End KeyFormList
-
- On MakeCompareList
- put field "compareList" into compareList
- put "" into rst
- put number of items in compareList into n
- repeat with i = 1 to n
- put item i of compareList & return after rst
- end repeat
- put rst into field "pickList"
- End MakeCompareList
-
- Function PropNameToCode classCode, propName
- put field "classNameList" into classNameList
- put number of lines in classNameList into n
- repeat with i = 1 to n
- if classCode = item 1 of line i of classNameList then
- put line i of classNameList into classInfo
- put (number of items in classInfo) div 2 - 1 into propCount
- put 3 into j
- repeat propCount times
- if item j of classInfo = propName then
- return item j+1 of classInfo
- end if
- add 2 to j
- end repeat
- exit repeat
- end if
- end repeat
- return "????"
- End PropNameToCode
-
- Function PropCodeToName classCode, propCode
- put field "classNameList" into classNameList
- put number of lines in classNameList into n
- repeat with i = 1 to n
- if classCode = item 1 of line i of classNameList then
- put line i of classNameList into classInfo
- put (number of items in classInfo) div 2 - 1 into propCount
- put 4 into j
- repeat propCount times
- if item j of classInfo = propCode then
- return item j-1 of classInfo
- end if
- add 2 to j
- end repeat
- exit repeat
- end if
- end repeat
- return "????"
- End PropCodeToName
-
- on MakePickList classCode, stateCode
- put stateCode into nextCode
- if (stateCode = "pickObj1") or (stateCode = "pickObj2") then
- put stateCode into last item of line 1 of field "cardState"
- if stateCode = "pickObj1" then
- put "Search" && ClassCodeToName(classCode) && "whose" into field "operation"
- else if stateCode = "pickObj2" then
- put number of items in line 2 of field "cardState" into x
- put item (x-1) of line 2 of field "cardState" into classCode
- put classCode into item x of line 2 of field "cardState"
- end if
- put "pickElem" into nextCode
- else if stateCode = "pickElem" then
- put "Click to select an element or property of this" && ClassCodeToName(classCode)&":" into field "operation"
- end if
- if (nextCode = "pickElem") then
- put ElementList(classCode) into x
- if stateCode = "pickObj1" then
- delete line 1 of x
- else if stateCode = "pickObj2" then
- put "constant" into line 1 of x
- end if
- put propertyList(classCode) after x
- put x into field "pickList"
- put classCode into last item of line 2 of field "cardState"
- put "," & stateCode after line 1 of field "cardState"
- end if
- end MakePickList
-
- function UnParse theCode,startIndex,container
- put length(theCode) into n
- repeat while startIndex <= n
- put char startIndex to (startIndex+3) of theCode into curCode
- put char (startIndex+4) to (startIndex+7) of theCode into curType
- if container <> "" then
- put ", " & container into container
- end if
- if curType = "prop" then
- put "AEObjectSpec(" & quote & prop & quote & ", " & quote & "prop" ¬
- & quote & ", " & quote & curCode & quote & container & ")" into container
- add 8 to startIndex
- else if curType = "test" then
- add 9 to startIndex
- put UnParse(theCode,startIndex,"Exmn()") into temp
- put line 1 of temp into obj1
- put line 2 of temp into startIndex
- put char (startIndex) to (startIndex+3) of theCode into compCode
- add 5 to startIndex
- put UnParse(theCode,startIndex,"Exmn()") into temp
- put line 1 of temp into obj2
- put line 2 of temp into startIndex
- put "AEObjectSpec(" & quote & curCode & quote & ", test, " & ¬
- "AECompareSpec(" & quote & compCode & quote & "," & obj1 & "," ¬
- & obj2 & ")" & container & ")" into container
- else
- add 9 to startIndex
- put startIndex into orgIndex
- repeat until char startIndex of theCode = ")"
- add 1 to startIndex
- end repeat
- put char orgIndex to (startIndex-1) of theCode into v
- add 1 to startIndex
- if (curType = "cnst") and (curCode = "cnst") then
- put quote & v & quote into container
- else
- put "AEObjectSpec(" & quote & curCode & quote & ", " & ¬
- quote & curType & quote & ", " & v & container & ")" into container
- end if
- end if
- put char startIndex of theCode into temp
- add 1 to startIndex
- if temp <> "." then
- exit repeat
- end if
- end repeat
- return container & return & startIndex
- end UnParse
-
- On ChunkComplete
- delete last item of line 1 of field "cardState"
- put last item of line 1 of field "cardState" into curState
- if curState = "pickObj1" then
- put "pickCmpr" into last item of line 1 of field "cardState"
- put "," after field "chunkExp"
- MakeCompareList
- else if curState = "pickObj2" then
- put ")." after field "chunkExp"
- put last item of line 2 of field "cardState" into temp
- delete last item of line 1 of field "cardState"
- delete last item of line 2 of field "cardState"
- MakePickList temp,"pickElem"
- else if curState = "done" then
- put "1. Click parameters to select them. 2. Then click handler names to copy them to the messages field below:" into field "operation"
- put "" into field "pickList"
- put line 1 of UnParse(field "chunkExp", 1) into temp
- PutMyMsgBox temp
- set name of bkgnd button id 6 to "obj"
- Show field "eventList"
- end if
- End ChunkComplete
-
- function isTempDesc theStr
- if (CharToNum(char 1 of theStr) = 190) then
- if (CharToNum(char 6 of theStr) = 190) then
- global createdDesc
- put number of items in createdDesc into n
- repeat with i = 1 to n
- if item i of createdDesc = theStr then
- return true
- end if
- end repeat
- end if
- end if
- return false
- end isTempDesc
-
- Function FirstItemOfEachLine theList
- put "" into rst
- put number of lines of theList into n
- repeat with i = 1 to n
- put item 1 of line i of theList into x
- if x <> "mouseUp" and x <> "mouseWithin" then
- put x & return after rst
- end if
- end repeat
- return rst
- End FirstItemOfEachLine
-
- Function AllHandlerName theScript
- put "" into mosueUpInfo
- put number of lines of theScript into n
- put "" into handlerList
- repeat with i = 1 to n -- find where the script is
- if word 1 of line i of theScript = "on" then
- put 0 into endHandler
- put word 2 of line i of theScript into handlerName
- put i+1 into beginHandler
- repeat with j = beginHandler to n
- if word 1 of line j of theScript = "end" ¬
- and word 2 of line j of theScript = handlerName then
- put j-1 into endHandler
- exit repeat
- end if
- end repeat
- put j into i
- if endHandler <> 0 then
- if handlerName = "mouseUp" then
- put handlerName & "," & beginHandler & "," & endHandler into mouseUpInfo
- else if handlerName = "mouseWithin" then
- else
- put handlerName & "," & beginHandler & "," & endHandler & return after handlerList
- end if
- end if
- end if
- end repeat
- if mouseUpInfo <> "" then put mouseUpInfo & return after handlerList
- return handlerList
- End AllHandlerName
-
- On PickMouseUpScript
- put the script of target into btnScript
- if the optionKey is down then
- -- we just execute the first script
- put number of lines in btnScript into n
- repeat with i = 1 to n
- if word 1 of line i of btnScript = "on" then
- put word 2 of line i of btnScript into handlerName
- if (handlerName <> "mouseUp") and (handlerName <> "mouseWithin") then
- send handlerName to the target
- exit repeat
- end if
- end if
- end repeat
- else
- put AllHandlerName(btnScript) into handlerInfoList -- list of all handlers
- put false into done
- repeat until done
- put ShowList(FirstItemOfEachLine(handlerInfoList), ¬
- "Pick a handler to Execute or all the handlers to exprt", ¬
- true, true, "Execute,Edit,Export,Cancel",1) into temp
- put line 1 of temp into action
- if (action = "Execute") or (action = "Edit") then
- put number of items in line 2 of temp into n
- if n > 1 then
- -- you selected too many
- answer "Too many handlers have been selected" with "Retry" or "Cancel"
- if it = "Cancel" then
- put true into done
- end if
- else
- if n = 1 then
- put line 2 of temp into i
- put item 1 of line i of handlerInfoList into handlerName
- if i <> 1 then
- -- move it to the front
- put (item 2 of line i of handlerInfoList) - 1 into sc1
- put (item 3 of line i of handlerInfoList) + 1 into sc2
- get line sc1 to sc2 of btnScript
- if line sc2+1 of btnScript = "" then
- add 1 to sc2
- end if
- delete line sc1 to sc2 of btnScript
- put it & return & return before btnScript
- Set the script of target to btnScript
- end if
- if action = "Execute" then
- send handlerName to the target
- else
- edit the script of the target
- end if
- end if
- put true into done
- end if
- else
- put true into done
- if action = "Export" then
- -- make self executing script stack
- put field "targetApp" into appName
- put appName & " glue stack" into glueName
- if there is no stack glueName then
- put short name of this stack into myStackName
- -- copy script from the stack script and card script
- put script of this stack into thisScript
- put return & script of this card after thisScript
- create stack glueName in a new window
- if the result = "" then
- set the script of stack glueName to thisScript
- domenu "Close Stack"
- CopyRes "XCMD",3327,myStackName,glueName
- CopyRes "XCMD",3331,myStackName,glueName
- CopyRes "XCMD",3336,myStackName,glueName
- CopyRes "XFCN",3328,myStackName,glueName
- CopyRes "XFCN",3329,myStackName,glueName
- CopyRes "XFCN",3330,myStackName,glueName
- CopyRes "XFCN",3337,myStackName,glueName
- CopyRes "XFCN",3338,myStackName,glueName
- CopyRes "XFCN",3339,myStackName,glueName
- CopyRes "XFCN",3340,myStackName,glueName
- CopyRes "XFCN",3341,myStackName,glueName
- CopyRes "XFCN",3342,myStackName,glueName
- end if
- end if
- put quote & appName & quote into appName
- put quote & glueName & quote into glueName
- put line 2 of temp into makeScriptList
- put number of items in makeScriptList into n
- repeat with i = 1 to n
- put item i of makeScriptList into j
- put item 1 of line j of handlerInfoList into handlerName
- put item 2 of line j of handlerInfoList into beginHandler
- put item 3 of line j of handlerInfoList into endHandler
- put line beginHandler to endHandler of btnScript into thisScript
- ask file "Make a self-executing stack with name:" with handlerName
- if the result <> "Cancel" and it <> "" then
- put it into handlerName
- if there is a stack "Self-executing Stack ProtoType" then
- save stack "Self-executing Stack ProtoType" as stack handlerName
- if the result = "" then
- go to stack handlerName in a new window
- end if
- else
- create stack handlerName in a new window
- if the result = "" then
- set the rect of this card to "0,0,64,64"
- set the loc of card window to "0,40"
- end if
- end if
- if the result = "" then
- put "On OpenStack" & return ¬
- & "if the optionKey is down then" & return & "Edit the script of me" & return ¬
- & "else" & return & "Hide card window" & return ¬
- & "Start Using Stack " & glueName & return ¬
- & "MakeSureLaunched" && appName & return before thisScript
- put return & "Stop Using Stack " & glueName & return ¬
- & "if the enabled of menuitem 3 of menu file then" & return ¬
- & "doMenu " & quote & "Close Stack" & quote & return ¬
- & "else" & return & "doMenu" & quote & "Quit HyperCard" & quote ¬
- & return & "end if" & return & "end if" & return ¬
- & "End OpenStack" after thisScript
- set the script of stack handlerName to thisScript
- domenu "Close Stack"
- end if
- end if
- end repeat
- end if
- end if
- end repeat
- end if
- End PickMouseUpScript
- </script>
- </background>
-